package 对象;

public class giftFriendText {
    public static void main(String[] args) {
        //定义数组存储4个女朋友的对象
        giftFriend[] all = new giftFriend[4];
        giftFriend g1 = new giftFriend("小诗诗" , 19 , '女' , "喜欢吃零食");
        giftFriend g2 = new giftFriend("小巧桥" , 20 , '女' , "喜欢运动");
        giftFriend g3 = new giftFriend("小况况" , 21 , '女' , "喜欢打游戏");
        giftFriend g4 = new giftFriend("小库库" , 19 , '女' , "喜欢玩电脑");
        all[0] = g1;
        all[1] = g2;
        all[2] = g3;
        all[3] = g4;
        for (int i = 0; i < all.length; i++) {
            System.out.print(all[i].getName() + " ");
            System.out.print(all[i].getAge() + " ");
            System.out.print(all[i].getXb() + " ");
            System.out.print(all[i].getHobby() + " ");
            System.out.println();
        }

        //换行处理
        System.out.println();
        double result = ( all[0].getAge() + all[1].getAge() + all[2].getAge() + all[3].getAge() ) / all.length;
        //计数器
        int count = 0;
        for (int i = 0; i < all.length; i++) {
            if ( all[i].getAge() <= result) {
                count++;
                System.out.print(all[i].getName() + " ");
                System.out.print(all[i].getAge() + " ");
                System.out.print(all[i].getXb() + " ");
                System.out.print(all[i].getHobby() + " ");
                System.out.println();
            }
        }
        System.out.println(count + "个");

    }
}
